module GeeePay
  class Result
    attr_accessor :raw, :msg

    RESULT_SUCCESS_FLAG = '1'


    # 网关支付-银行编码
    LV_BANK_CODE_MAP = {
        '102' => '工商银行',
        '103' => '农业银行',
        '104'	=> '中国银行',
        '105'	=> '建设银行',
        '203' => '农业发展银行',
        '301'	=> '交通银行',
        '302' => '中信银行',
        '303' => '光大银行',
        '304'	=> '华夏银行',
        '305' => '民生银行',
        '306'	=> '广发银行',
        '307'	=> '平安银行',
        '308'	=> '招商银行',
        '309'	=> '兴业银行',
        '310'	=> '浦发银行',
        '313'	=> '北京银行',
        '315' => '恒丰银行',
        '316' => '浙商银行',
        '318' => '渤海银行',
        '325' => '上海银行',
        '403' => '邮储银行',
        '440' => '徽商银行'
    }

    # 扫码支付方式
    LV_SCAN_PAY_MODE = {
        '00021' => '支付宝扫码',
        '00022' => '微信扫码',
        '00032' => 'QQ扫码',
        '00027' => '京东扫码'
    }

    LV_PAY_MODE = {
        '00020' => '银行卡',
        '00023' => '快捷',
        '00024' => '支付宝Wap'
    }

    # 到账类型
    LV_RECEIVABLE_TYPE = { 'D00' => 'D+0', 'T01' => 'T+1', 'D01' => 'D+1'}

    # 业务类型
    LV_WITHDRAW_TYPE = { '0' => '对私', '1' => '对公' }

    # 账户类型
    LV_ACCOUNT_TYPE = { '0' => '借记卡', '1' => '贷记卡' }

    # 订单状态：交易订单
    LV_TRAN_ORDER_STATUS= {
        '00' => '未支付',
        '01' => '支付成功',
        '02' => '银行处理中',
        '14' => '冻结',
        '19' => '待处理'
    }

    # 订单状态：代付订单
    LV_OTH_ORDER_STATUS = {
        '00' => '未支付',
        '01' => '已完成',
        '14' => '冻结',
        '02' => '银行处理中',
        '22' => '退还支付账户'
    }

    def initialize(result)
      self.raw = result.to_s
      self.msg = result
    end

    def success?
      @msg['returnCode'] == RESULT_SUCCESS_FLAG
    end
  end
end